package com.wcsy.myblog.service.serviceImpl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wcsy.myblog.dao.QQMapper;
import com.wcsy.myblog.entity.Qq;
import com.wcsy.myblog.entity.User;
import com.wcsy.myblog.service.IQQService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

@Service
public class QQServiceImpl extends ServiceImpl<QQMapper, Qq> implements IQQService {
    @Autowired
    QQMapper qqMapper;
    @Autowired
    HttpSession session;
    @Override
    public void insertQq() {
        //获取用户qq登陆的标识id
        String openID = (String) session.getAttribute("openID");
        Qq qq = new Qq();
        qq.setOpenId(openID);
        User user1 = (User) session.getAttribute("user");
        qq.setUserId(user1.getUserId());
        qqMapper.insertQq(qq);
    }

    @Override
    public void insertQq(int userId, String openId) {
        Qq qq = new Qq();
        qq.setOpenId(openId);
        qq.setUserId(userId);
        qqMapper.insertQq(qq);
    }
}
